
# 此脚本只是在机器上安装完成kubeadm/kubectl/kubelet
# 后续配置需要再配. 
# 比如加入节点的  网桥转发,需要手工配置.

echo "join node ,加入节点,做检查和基本配置 "

check(){
	# 检查,确保可以正常安装. 
	
	# docker 判断是否启动
    # TODO

	# swap 关闭
	counter2=`free -m | grep Swap | awk '{print $2}'`
	if [ $counter2 -gt 0 ] ;
        then
                echo "swap 未关闭,请先关闭"
                exit 1 
        fi
	# selinux关闭检查
	selinuxstatus=`getenforce`
	if [ $selinuxstatus -eq 'Disabled' ] ;
        then
                echo "selinux 未关闭,请先关闭"
                exit 1 
        fi
}

down_images_node(){
	docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:$1
	docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:$1 k8s.gcr.io/kube-proxy:$1
	docker rmi -f registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:$1

	docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:$2
	docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:$2 k8s.gcr.io/pause:$2
	docker rmi -f registry.cn-hangzhou.aliyuncs.com/google_containers/pause:$2
}
config_env(){
	# 1.配置网桥转发
	echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables
	# 2.配置kubelet自启动.
	systemctl enable kubelet
}


# 加入节点
check
down_images_node v1.13.1 3.1
config_env